<?php

namespace app\admin\model;

use think\Model;
use traits\model\SoftDelete;

class Tickets extends Model
{

    use SoftDelete;

    

    // 表名
    protected $name = 'tickets';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'datetime';
    protected $dateFormat = 'Y-m-d H:i:s';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'type_text',
        'reissue_type_text',
        'reissue_type_zero_text',
        'reissue_type_one_text',
        'coupon_status_text',
        'cancel_type_text',
        'cancel_type_zero_text',
        'cancel_type_one_text',
        'cancel_type_one_two_text',
        'addressee_type_text',
        'addressee_type_zero_text',
        'addressee_type_one_text',
        'status_text',
        'shops_id_text',
    ];

    public function getShopsIdTextAttr($value,$data)
    {
        $shops = Shops::shopsByIdIndexListStatic();
        return $shops[$data['shops_id']];
    }

    
    public function getTypeList()
    {
        return ['0' => __('Type 0'), '1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3'), '4' => __('Type 4')];
    }

    public function getReissueTypeList()
    {
        return ['0' => __('Reissue_type 0'), '1' => __('Reissue_type 1'), '2' => __('Reissue_type 2')];
    }

    public function getReissueTypeZeroList()
    {
        return ['0' => __('Reissue_type_zero 0'), '1' => __('Reissue_type_zero 1'), '2' => __('Reissue_type_zero 2')];
    }

    public function getReissueTypeOneList()
    {
        return ['0' => __('Reissue_type_one 0'), '1' => __('Reissue_type_one 1'), '2' => __('Reissue_type_one 2'), '3' => __('Reissue_type_one 3'), '4' => __('Reissue_type_one 4'), '5' => __('Reissue_type_one 5')];
    }

    public function getCouponStatusList()
    {
        return ['0' => __('Coupon_status 0'), '1' => __('Coupon_status 1'), '2' => __('Coupon_status 2')];
    }

    public function getCancelTypeList()
    {
        return ['0' => __('Cancel_type 0'), '1' => __('Cancel_type 1'), '2' => __('Cancel_type 2')];
    }

    public function getCancelTypeZeroList()
    {
        return ['0' => __('Cancel_type_zero 0'), '1' => __('Cancel_type_zero 1'), '2' => __('Cancel_type_zero 2')];
    }

    public function getCancelTypeOneList()
    {
        return ['0' => __('Cancel_type_one 0'), '1' => __('Cancel_type_one 1'), '2' => __('Cancel_type_one 2'), '3' => __('Cancel_type_one 3')];
    }

    public function getCancelTypeOneTwoList()
    {
        return ['0' => __('Cancel_type_one_two 0'), '1' => __('Cancel_type_one_two 1'), '2' => __('Cancel_type_one_two 2')];
    }

    public function getAddresseeTypeList()
    {
        return ['0' => __('Addressee_type 0'), '1' => __('Addressee_type 1'), '2' => __('Addressee_type 2')];
    }

    public function getAddresseeTypeZeroList()
    {
        return ['0' => __('Addressee_type_zero 0'), '1' => __('Addressee_type_zero 1'), '2' => __('Addressee_type_zero 2')];
    }

    public function getAddresseeTypeOneList()
    {
        return ['0' => __('Addressee_type_one 0'), '1' => __('Addressee_type_one 1'), '2' => __('Addressee_type_one 2')];
    }

    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getReissueTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['reissue_type']) ? $data['reissue_type'] : '');
        $list = $this->getReissueTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getReissueTypeZeroTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['reissue_type_zero']) ? $data['reissue_type_zero'] : '');
        $list = $this->getReissueTypeZeroList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getReissueTypeOneTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['reissue_type_one']) ? $data['reissue_type_one'] : '');
        $list = $this->getReissueTypeOneList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getCouponStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['coupon_status']) ? $data['coupon_status'] : '');
        $list = $this->getCouponStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getCancelTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['cancel_type']) ? $data['cancel_type'] : '');
        $list = $this->getCancelTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getCancelTypeZeroTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['cancel_type_zero']) ? $data['cancel_type_zero'] : '');
        $list = $this->getCancelTypeZeroList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getCancelTypeOneTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['cancel_type_one']) ? $data['cancel_type_one'] : '');
        $list = $this->getCancelTypeOneList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getCancelTypeOneTwoTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['cancel_type_one_two']) ? $data['cancel_type_one_two'] : '');
        $list = $this->getCancelTypeOneTwoList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getAddresseeTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['addressee_type']) ? $data['addressee_type'] : '');
        $list = $this->getAddresseeTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getAddresseeTypeZeroTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['addressee_type_zero']) ? $data['addressee_type_zero'] : '');
        $list = $this->getAddresseeTypeZeroList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getAddresseeTypeOneTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['addressee_type_one']) ? $data['addressee_type_one'] : '');
        $list = $this->getAddresseeTypeOneList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
